<?php
require_once("tasktypeView.php");
require_once(CORE_DIR.'tasktypeModel.php');

class addAction extends authAction{

	function __construct(){
		$this->view = new tasktypeView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$ttModel = new tasktypeModel();		
		if (isset($get["name"])){
			$tsktypeName = htmlspecialchars($get["name"], ENT_QUOTES);
			$tsktypeDesc = htmlspecialchars($get["desc"], ENT_QUOTES);
			
			$lastInsertId = $ttModel->addTaskType($tsktypeName, $tsktypeDesc);	
			$status = 0;
			$id = 0;
			if ($lastInsertId > 0){
				$status = 1;
				$id = $lastInsertId;
			}
			
			$this->view->setProperty("status", $status);
			$this->view->setProperty("id", $id);
			$this->view->showAddTaskType();
		}
		else{
			$this->view->showBadCmd();
		}	
			
	}
}
?>